package com.njym.java.security.admin.rest;

import com.njym.java.security.admin.biz.TeacherBiz;
import com.njym.java.security.admin.entity.Teacher;
import com.njym.java.security.common.rest.BaseController;
import com.njym.java.security.common.util.ResponseUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import tk.mybatis.mapper.entity.Example;

@Controller
@RequestMapping("teacher")
public class TeacherController extends BaseController<TeacherBiz, Teacher> {

	@RequestMapping(value = "/list", method = RequestMethod.GET)
	@ResponseBody
	public Object list(String name) {
		Example example = new Example(Teacher.class);
		if (StringUtils.isNotBlank(name)) {
			example.createCriteria().andLike("name", "%" + name + "%");
		}
		return ResponseUtil.ok(baseBiz.selectByExample(example));
	}
}